#include <stdio.h>
#include <stdlib.h>
struct Node {
    int data;
    struct Node* next;
};
struct Node* createLinkedList(int n) {
    struct Node* head = NULL;
    struct Node* tail = NULL;
    for (int i = 0; i < n; i++) {
        int val;
        scanf("%d", &val);
        struct Node *newNode = (struct Node*)malloc(sizeof(struct Node));
        newNode->data = val;
        newNode->next = NULL;
        
        if (head == NULL) {
            head = newNode;
            tail = newNode;
        } else {
            tail->next = newNode;
            tail = newNode;
        }
    }
    
    return head;
}

void splitLinkedList(struct Node* head) {
    struct Node* oddHead = NULL;
    struct Node* evenHead = NULL;
    struct Node* oddTail = NULL;
    struct Node* evenTail = NULL;
    
    int position = 1;
    struct Node* current = head;
    while (current != NULL) {
        if (position % 2 == 1) {
            if (oddHead == NULL) {
                oddHead = current;
                oddTail = current;
            } else {
                oddTail->next = current;
                oddTail = current;
            }
        } else {
            if (evenHead == NULL) {
                evenHead = current;
                evenTail = current;
            } else {
                evenTail->next = current;
                evenTail = current;
            }
        }
        position++;
        current = current->next;
    }
    
    // Set the last node's next to NULL for both odd and even lists
    if (oddTail != NULL) {
        oddTail->next = NULL;
    }
    if (evenTail != NULL) {
        evenTail->next = NULL;
    }
    
    // Print the odd list
    current = oddHead;
    while (current != NULL) {
        printf("%d ", current->data);
        current = current->next;
    }
    printf("\n");
    
    // Print the even list
    current = evenHead;
    while (current != NULL) {
        printf("%d ", current->data);
        current = current->next;
    }
    printf("\n");
}

int main() {
    int n;
    scanf("%d", &n);
    struct Node* head = createLinkedList(n);
    splitLinkedList(head);
    return 0;
}
